<?php
namespace Plugin\Alarm\Schema;

use Plugin\Alarm\Model\RdAlarmWork;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 工单记录
 */
#[Schema(title: 'RdAlarmWorkSchema')]
class RdAlarmWorkSchema implements \JsonSerializable
{
    #[Property(property: 'id', title: 'id', type: 'bigint')]
    public string $id;

    #[Property(property: 'title', title: '工单标题', type: 'string')]
    public string $title;

    #[Property(property: 'content', title: '工单内容', type: 'string')]
    public string $content;

    #[Property(property: 'status', title: '工单状态', type: 'tinyint')]
    public string $status;

    #[Property(property: 'stand_id', title: '站点ID', type: 'bigint')]
    public string $stand_id;

    #[Property(property: 'user_id', title: '工单处理人ID', type: 'bigint')]
    public string $user_id;

    #[Property(property: 'type', title: '工单类型1:AI告警工单2:AI隐患工单3:人工提报工单', type: 'int')]
    public string $type;

    #[Property(property: 'expire_times', title: '延期次数', type: 'int')]
    public string $expire_times;

    #[Property(property: 'expire_at', title: '整改限期', type: 'timestamp')]
    public string $expire_at;

    #[Property(property: 'priority', title: '工单优先级1:普通2:紧急3:非常紧急', type: 'tinyint')]
    public string $priority;

    #[Property(property: 'related_type', title: '工单关联类型1:告警2:隐患3:其他', type: 'tinyint')]
    public string $related_type;

    #[Property(property: 'related_id', title: '关联ID', type: 'bigint')]
    public string $related_id;

    #[Property(property: 'extra', title: '工单附加信息', type: 'json')]
    public string $extra;

    #[Property(property: 'created_by', title: '创建人', type: 'bigint')]
    public string $created_by;

    #[Property(property: 'updated_by', title: '更新人', type: 'bigint')]
    public string $updated_by;

    #[Property(property: 'created_at', title: 'created_at', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: 'updated_at', type: 'timestamp')]
    public string $updated_at;

    public function __construct(RdAlarmWork $model)
    {
       $this->id = $model->id;
       $this->title = $model->title;
       $this->content = $model->content;
       $this->status = $model->status;
       $this->stand_id = $model->stand_id;
       $this->user_id = $model->user_id;
       $this->type = $model->type;
       $this->expire_times = $model->expire_times;
       $this->expire_at = $model->expire_at;
       $this->priority = $model->priority;
       $this->related_type = $model->related_type;
       $this->related_id = $model->related_id;
       $this->extra = $model->extra;
       $this->created_by = $model->created_by;
       $this->updated_by = $model->updated_by;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;
    }

    public function jsonSerialize(): array
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'content' => $this->content,
            'status' => $this->status,
            'stand_id' => $this->stand_id,
            'user_id' => $this->user_id,
            'type' => $this->type,
            'expire_times' => $this->expire_times,
            'expire_at' => $this->expire_at,
            'priority' => $this->priority,
            'related_type' => $this->related_type,
            'related_id' => $this->related_id,
            'extra' => $this->extra,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at
        ];
    }
}